﻿using System;
using System.Data;
using System.Linq;
using WPFExcelReport.Helpers;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        private void JLTVKSS(DataSet db)
        {
            try
            {
                #region------------------准确的格式---
                //DataTable tbVKPOS = db.Tables["VKPOS"];
                //DataTable dtOutput = new DataTable();
                //int idx = 1;
                //#region======Title===========
                //exAgent.SetCellValue(2, idx++, "品种号"); dtOutput.Columns.Add("VKPART", typeof(System.String));
                //exAgent.SetCellValue(2, idx++, "花型号"); dtOutput.Columns.Add("VKPFARBE", typeof(System.String));         
                //exAgent.SetCellValue(2, idx++, "订单数量"); dtOutput.Columns.Add("VKPMENGE1", typeof(System.String));
                //exAgent.SetCellValue(2, idx++, "单位"); dtOutput.Columns.Add("VKPMEEH", typeof(System.String));
                //exAgent.SetCellValue(2, idx++, "交期"); dtOutput.Columns.Add("VKPLIEFTERM", typeof(System.String));
                //exAgent.SetCellValue(2, idx++, "贸易条件"); dtOutput.Columns.Add("VKKLIEFBED", typeof(System.String));
                //exAgent.SetCellValue(2, idx++, "业务员"); dtOutput.Columns.Add("VKKSACHBE", typeof(System.String));
                //exAgent.SetCellValue(2, idx++, "客户"); dtOutput.Columns.Add("KDKUNDNA", typeof(System.String));
                //exAgent.SetCellValue(2, idx++, "目的地"); 
                //exAgent.SetCellValue(2, idx++, "港口"); 
                //#endregion
                //dtOutput.Merge(tbVKPOS, false, MissingSchemaAction.Ignore);
                //exAgent.DataTableToExcel(dtOutput, 3, 1);
                //exAgent.SetCellValue(1, 1, 1);
                //int count = dtOutput.Rows.Count;
                //exAgent.BatchConvert2Number(3, 3, count + 2, 3);
                //exAgent.BatchConvert2Number(3, 5, count + 2, 5);
                //exAgent.SetCellValue(1, 1, "销售服务查询");
                #endregion
                 DataTable tbVKPOS = db.Tables["VKPOS"];  
                DataTable dtOutput = new DataTable(); 
                dtOutput.Merge(tbVKPOS, false, MissingSchemaAction.Ignore);
                //string ART = ""; string FARBE = ""; string MENGE1 = ""; string ARTNAME = ""; string DESC = ""; 
                string art = "";
                string farbe = "";
                string menge1 = "";
                string meeh = "";
                string LIEFTERM = "";
                string liefbed = "";
                string SACHBE="";
                string KUNDNA="";
                string DESCR = "";
                
                //DataRow VKP=tbVKPOS.Rows[0];
               //,,VKPOFFEN,VKPMEEH,VKPLIEFTERM,VKKLIEFBED,KDKUNDNA
                exAgent.SetCellValue(1, 1, "销售服务查询");
                exAgent.SetCellValue(2, 1, "品种号");
                exAgent.SetCellValue(2, 2, "颜色号");
                exAgent.SetCellValue(2, 3, "订单数量");
                exAgent.SetCellValue(2, 4, "单位");
                exAgent.SetCellValue(2, 5, "交期");
                exAgent.SetCellValue(2, 6, "贸易条件");
                exAgent.SetCellValue(2, 7, "业务员");
                exAgent.SetCellValue(2, 8, "客户");
                exAgent.SetCellValue(2, 9, "目的地");
                exAgent.SetCellValue(2, 10, "港口");
                for (int i = 0; i < tbVKPOS.Rows.Count; i++)
                {
                    string str1="";
                    string str2="";
                    string str3="";
                    DataRow VKP = tbVKPOS.Rows[i];
                    art = VKP["VKPART"].ToString().Trim();
                    farbe = VKP["VKPFARBE"].ToString().Trim();
                    menge1 = VKP["VKPMENGE1"].ToString().Trim();
                    meeh = VKP["VKPMEEH"].ToString().Trim();
                    LIEFTERM = VKP["VKPLIEFTERM"].ToString().Trim();
                    Helper.GetSplitDate( ref str1,ref str2,ref str3, LIEFTERM);
                    LIEFTERM = str3;
                    liefbed = VKP["VKPOSACHB"].ToString().Trim();
                    SACHBE = VKP["VKKSACHBE"].ToString().Trim();
                    KUNDNA = VKP["KDKUNDNA"].ToString().Trim();
                    DESCR = VKP["DESCR"].ToString().Trim();
                    DESCR = Helper.GetGB2312Value(DESCR).Trim();
                    exAgent.SetCellValue(i + 3, 1, art);
                    exAgent.SetCellValue(i + 3, 2, farbe);
                    exAgent.SetCellValue(i + 3, 3, menge1);
                    exAgent.SetCellValue(i + 3, 4, meeh);
                    exAgent.SetCellValue(i + 3, 5, LIEFTERM);
                    exAgent.SetCellValue(i + 3, 6, liefbed);
                    exAgent.SetCellValue(i + 3, 7, SACHBE);
                    exAgent.SetCellValue(i + 3, 8, KUNDNA);
                    exAgent.SetCellValue(i + 3, 9, DESCR);
                }     
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        } 
    }
}